package com.MedDroid.task;

import android.os.AsyncTask;
import com.MedDroid.activity.ViewProfileActivity;
import com.MedDroid.control.DatabaseControl;

import java.lang.ref.WeakReference;

/**
 * Created with IntelliJ IDEA.
 * User: Romen
 * Date: 03/12/13
 * Time: 12:33 AM
 * Description:
 */
public class DeleteUserTask extends AsyncTask<Void, Void, Void>
{
	DatabaseControl DatabaseC;
	WeakReference<ViewProfileActivity> ProfilePage;

	public DeleteUserTask(DatabaseControl Data, ViewProfileActivity activity)
	{
		DatabaseC = Data;
		ProfilePage = new WeakReference<ViewProfileActivity>(activity);
	}


	@Override
	protected Void doInBackground(Void... voids)
	{
		ViewProfileActivity Page = ProfilePage.get();
		DatabaseC.removeUser(Page.LoadedUser);
		return null;
	}

	@Override
	protected void onPostExecute(Void V)
	{
		ViewProfileActivity Page = ProfilePage.get();
		Page.finish();
	}
}
